package cn.caskm.souvenirshopsystem.controller.api;

import cn.caskm.souvenirshopsystem.domain.Result;
import cn.caskm.souvenirshopsystem.domain.dto.PageDTO;
import cn.caskm.souvenirshopsystem.domain.po.MessageWall;
import cn.caskm.souvenirshopsystem.domain.query.MessageWallQuery;
import cn.caskm.souvenirshopsystem.domain.vo.MessageWallVO;
import cn.caskm.souvenirshopsystem.service.MessageWallService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/messageWall")
@RequiredArgsConstructor
public class MessageWallController {

    private final MessageWallService messageWallService;

    @GetMapping("/page")
    public Result<PageDTO<MessageWallVO>> page(MessageWallQuery query) {
        return messageWallService.page(query);
    }

    @PostMapping("/publish")
    public Result<Void> publishMessage(@RequestBody MessageWall messageWall) {
        return messageWallService.publishMessage(messageWall);
    }

    @DeleteMapping("/{messageId}")
    public Result<Void> deleteMessage(@PathVariable("messageId") Integer messageId) {
        return messageWallService.deleteMessage(messageId);
    }

}
